<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;

class CreateOrdersTable extends Migration {

	/**
	 * Run the migrations.
	 *
	 * @return void
	 */
	public function up()
	{
		Schema::create('orders', function(Blueprint $table)
		{
			$table->increments('id');
			$table->integer('customer_id')->default(0);
			$table->integer('store_id')->default(0);
			$table->integer('device_account_id')->default(0);
			$table->integer('product_id')->default(0)->comment('商品id');
			$table->string('trad_no')->nullable();
			$table->boolean('order_type')->nullable()->default(1)->comment('订单类型 1 默认为有赞，暂时没有其他类型订单');
			$table->string('status_str')->nullable()->comment('订单状态');
			$table->string('pay_time')->nullable()->comment('支付时间');
			$table->integer('num')->default(0)->comment('商品数量');
			$table->decimal('price', 10)->default(0.00)->comment('单价');
			$table->decimal('total_fee', 10)->nullable()->default(0.00)->comment('订单总价');
			$table->string('buyer')->nullable();
			$table->integer('refund_state')->nullable()->default(0)->comment('总订单的退款状态');
			$table->text('product_json_data', 65535)->nullable()->comment('商品json数组，商品缩略图和商品标题');
			$table->string('created_at')->nullable();
			$table->string('updated_at')->nullable();
		});
	}


	/**
	 * Reverse the migrations.
	 *
	 * @return void
	 */
	public function down()
	{
		Schema::drop('orders');
	}

}
